#include <stdio.h>
#include <stdlib.h>
struct node
{
    int data;
    struct node* next;
};
struct node* create()
{
    struct node* head = NULL, * p = NULL;
    while (1)
    {
        p=(struct node*)malloc(sizeof(struct node));
        scanf("%d", &p->data);
        if (p->data == 0)
        {
            break;
        }
        else
        {
            p->next = head;
            head = p;
        }
    }
    return head;
}
void print(struct node* head)
{
    struct node* p = head;
    while (p)
    {
        printf("%d ", p->data);
        p = p->next;
    }
}
int main()
{
    struct node* haed = NULL;
    haed = create();
    print(haed);
    return 0;
}
